<template>
  <div class="container-xl bg-white">
    <div class="row">
      <div class="col">
        <div v-html="data.context" class="editor-content-view"></div>
      </div>
    </div>
    <div v-if="data.ID">
      <el-button @click="click(false)">拒绝</el-button>
      <el-button type="success" @click="click(true)">加入</el-button>
    </div>
  </div>
</template>

<script lang="ts">
import Studycodemodel from "../../../mysql_interface/studycodemodel";
import { computed, defineComponent, reactive } from "vue";
import { useStore } from "vuex";
import { asyncaddteamlog, asyncgetmynotice } from "../../../api/index";
import { useRoute } from "vue-router";
import { ElMessage } from "element-plus";
import { Storekey } from "../../../interface";
export default defineComponent({
  props: ["ID"],
  setup(p) {
    const data = reactive<Studycodemodel.Inotice>({});
    const router = useRoute();
    const query = computed(() => {
      return router.query as { teamid?: string };
    });
    const store = useStore(Storekey);
    const user = computed<Studycodemodel.Iuser>(() => {
      return store.getters.getuser;
    });
    async function start() {
      if (p.ID && query.value.teamid) {
        const { rows } = await asyncgetmynotice({
          ID: p.ID,
        });
        if (rows.length) {
          Object.assign(data, rows[0]);
        }
      }
    }
    async function click(type: boolean) {
      if (query.value.teamid) {
        const n = type ? "申请" : "拒绝";
        await asyncaddteamlog({
          teamid: Number(query.value.teamid),
          userid: user.value.ID,
          type: n,
        });
        if (type) {
          ElMessage.success("加入成功");
        } else {
          ElMessage.info("与拒绝");
        }
      }
    }
    return {
      data,
      click,
    };
  },
});
</script>


<style scoped>
</style>
